import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
import path from 'path'
export default defineConfig({
  base:'/backend',
  plugins: [
    vue(),
    Components({
      dts: 'src/components.d.ts',
      deep: true,
      dirs: ['src/components'],
      extensions: ['vue', 'tsx'],
      resolvers: [
        AntDesignVueResolver({
          importStyle: 'less',
          importLess: true,
        }),
      ],
    }),
  ],
  resolve: {
      alias: {
        '@': path.resolve(__dirname, 'src')
      },
      extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json']
  },
  server: {
    port: 3011,
    host: "0.0.0.0",
    proxy: {
      '/api': {
        target: 'https://cloud.whmoyun.com/api',
        changeOrigin: true,
        secure : false,
        ws: true,
        rewrite: (pathStr) => pathStr.replace(/^\/api/, '')
      },
    },
  },
  css: {
    preprocessorOptions: {
      less: {
        modifyVars: {
          '@primary-color': '#20d6cc',
          '@layout-sider-background':'#20d6cc'
        },
        javascriptEnabled: true
      }
    }
  }
})
